﻿#include "manglobal.h"
#include "src/bend/man/gateway.h"
#include "src/bend/man/mancloud.h"
#include "src/bend/man/mandb.h"
#include "src/config/globals.h"
#include "src/config/loggerproxy.h"
#include "src/helper/filehelper.h"
#include "src/middle/manmodels.h"
#include "src/middle/signals/mansignals.h"
#include "src/plugins/manplugin.h"
#include <QApplication>
Q_GLOBAL_STATIC(ManGlobal, ins)

ManGlobal::ManGlobal(QObject* parent)
    : QObject(parent)
{
    mDb     = new ManDB(this);
    mPlugin = new ManPlugin(this);
    mCloud  = new ManCloud(this);
    mSignal = new ManSignals(this);
    mLog    = new LoggerProxy(this);
    mGate   = new GateWay(this);
}

ManGlobal::~ManGlobal() {}

ManGlobal* ManGlobal::instance()
{
    return ins();
}

void ManGlobal::init(int argc, char* argv[])
{
    mModels = new ManModels(this);
    FileHelper::mkPath(GLOBAL::PATH::TMP);

    QString qssStr = FileHelper::readAllTxt(":/static/qss/default.qss");
    qApp->setStyleSheet(qssStr);
    mPlugin->installPlugins(argc, argv);
    mDb->init();
}
